import * as userApi from '@/api/user.js';

export default {
	// 帐号登录
  login({ commit }, loginForm) {
	return new Promise((resolve, reject) => {
	  userApi
		.appCustomerLogin(loginForm, { showMessage: false, showError: false })
		.then(res => {
			console.log("res",res);
		  if (res.code === 0) {
			commit('hideSidebar');
			commit('setUserInfo', {...res.data, ...loginForm});
			resolve(res);
		  } else {
			reject(res);
		  }
		})
		.catch(err => {
		  reject(err);
		});
	});
  },
  wechatLogin({ commit }, data) {
  	return new Promise((resolve, reject) => {
  	  commit('setUserInfo', data);
	  resolve(data);
  	});
  }
};
